package cn.wolfcode.car.base.service.impl;

import cn.wolfcode.car.base.domain.Customer;
import cn.wolfcode.car.base.mapper.CustomerMapper;
import cn.wolfcode.car.base.service.ICustomerService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.common.base.query.QueryObject;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageInfo;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class CustomerServiceImpl implements ICustomerService {
    @Resource
    private CustomerMapper customerMapper;

    @Override
    public Customer queryById(Long id) {
        return customerMapper.queryById(id);
    }

    @Override
    public TablePageInfo<Customer> query(QueryObject qo) {
        PageHelper.startPage(qo.getPageNum(), qo.getPageSize());
        return new TablePageInfo<>(customerMapper.queryForList(qo));
    }

    @Override
    @Transactional
    public void save(Customer customer) {
        customerMapper.insert(customer);
    }

    @Override
    @Transactional
    public void update(Customer customer) {
        customerMapper.update(customer);
    }

    @Override
    @Transactional
    public void deleteBatch(String[] ids) {
        customerMapper.deleteBatch(ids);
    }
}
